import type { AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from "axios";

/**
 * 自定义拦截器类型
 */
export interface Interceptors<T = AxiosResponse> {
  requestSuccessFn?: (
    config: InternalAxiosRequestConfig
  ) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>;
  requestFailureFn?: (err: any) => any;
  responseSuccessFn?: (res: T) => T;
  responseFailureFn?: (err: any) => any;
}

/**
 * 针对于原有 axios 的配置进行二次封装(扩展)
 */
export interface RequestConfig<T = AxiosResponse> extends AxiosRequestConfig {
  interceptors?: Interceptors<T>;
}
